//
//  YHYAcitvityButtonTableViewCell.m
//  Home
//
//  Created by 杨泓晔 on 16/6/25.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYAcitvityButtonTableViewCell.h"

@implementation YHYAcitvityButtonTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

- (void)createSubView{
    
    //名字
    self.xmLabel = [[UILabel alloc]init];
    //self.xmLabel.textColor = HS;
    self.xmLabel.textColor = LINE;
    self.xmLabel.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    
    [self.contentView addSubview:_xmLabel];
    [self.xmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(3 * AUTO_HEIGHT);
        make.left.mas_equalTo(15.00 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(6*18.00*AUTO_WIDTH, 25.00*AUTO_HEIGHT));
    }];
    self.xmLabel.text = @"设计要求";
    
    
    
    
    
    UIImageView *imageL = [UIImageView new];
    imageL.image = [UIImage imageNamed:@"虚线"];
    [self.contentView addSubview:imageL];
    [imageL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_xmLabel.mas_bottom).offset(4 * AUTO_HEIGHT);
        make.left.mas_equalTo(8 * AUTO_WIDTH);
        make.right.mas_equalTo(self.contentView.mas_right).offset(- 8 * AUTO_WIDTH);
        make.height.mas_equalTo(1.5 * AUTO_HEIGHT);
        
    }];

    
    
    
    
    
    
    
    
    _firstB = [UIButton new];
    [self.contentView addSubview:_firstB];
    [_firstB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30 * AUTO_WIDTH);
        make.top.mas_equalTo(imageL.mas_bottom).offset(10 * AUTO_HEIGHT);
        make.width.mas_equalTo((((SCREEN_WIDTH - 30 * 2 * AUTO_WIDTH)- 30* AUTO_WIDTH * 2))/3);
        make.height.mas_equalTo(25 * AUTO_HEIGHT);
        
    }];
    
    _firstB.backgroundColor = KH;
    _firstB.layer.masksToBounds = YES;
    _firstB.layer.cornerRadius = 4 * AUTO_WIDTH;
    [_firstB setTitle:@"业主" forState:UIControlStateNormal];
    [_firstB setTitleColor:ZI forState:UIControlStateNormal];
    _firstB.tag = 1000;
    _firstB.titleLabel.font = [UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    [_firstB addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //预算
    _secondB = [UIButton new];
    [self.contentView addSubview:_secondB];
    [_secondB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_firstB);
        make.width.mas_equalTo((((SCREEN_WIDTH - 30 * 2 * AUTO_WIDTH)- 30* AUTO_WIDTH * 2))/3);
        make.left.mas_equalTo(_firstB.mas_right).offset(30 * AUTO_WIDTH);
        make.size.mas_equalTo(_firstB);
        
    }];
    _secondB.backgroundColor = KH;
    _secondB.layer.masksToBounds = YES;
    _secondB.layer.cornerRadius = 4 * AUTO_WIDTH;
    [_secondB setTitle:@"设计师" forState:UIControlStateNormal];
    [_secondB setTitleColor:ZI forState:UIControlStateNormal];
    _secondB.titleLabel.font = [UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    _secondB.tag = 1001;
    [_secondB addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //施工
    _thirdB = [UIButton new];
    [self.contentView addSubview:_thirdB];
    [_thirdB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_secondB);
        //make.left.mas_equalTo(_secondB.mas_right).offset(22 * AUTO_WIDTH);
        make.right.mas_equalTo(self).offset(-30*AUTO_WIDTH);
        make.size.mas_equalTo(_secondB);
        make.width.mas_equalTo((((SCREEN_WIDTH - 30 * 2 * AUTO_WIDTH)- 30* AUTO_WIDTH * 2))/3);
    }];
    _thirdB.backgroundColor = KH;
    _thirdB.layer.masksToBounds = YES;
    _thirdB.layer.cornerRadius = 4 * AUTO_WIDTH;
    [_thirdB setTitle:@"商家" forState:UIControlStateNormal];
    [_thirdB setTitleColor:ZI forState:UIControlStateNormal];
    _thirdB.titleLabel.font = [UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    _thirdB.tag = 1002;
    [_thirdB addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
      
}

- (void)button:(UIButton *)btu{
    //    _iselect2 = NO;
    //    _iselect3 = NO;
    //    _iselect4 = NO;
    if (btu.tag == 1000) {
        
        [self btu:btu];
    }
    if (btu.tag == 1001) {
        
        [self btu:btu];
        
    }
    if (btu.tag == 1002) {
        
        [self btu:btu];
    }
    if (btu.tag == 1003) {
         
        [self btu:btu];
    }
    
}

- (void)btu:(UIButton *)btu{
    btu.selected = !btu.selected;
    if (!btu.selected) {
        [btu setTitleColor:ZI forState:UIControlStateNormal];
        btu.backgroundColor = KH;
    }
    else{
        [btu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        btu.backgroundColor = GH;
    }
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
